//
//  ZLViewController.m
//  ZLPullMenu
//
//  Created by 赵振磊 on 05/27/2024.
//  Copyright (c) 2024 赵振磊. All rights reserved.
//

#import "ZLViewController.h"
#import <Masonry/Masonry.h>
#import <ZLPullMenu/ZLPullMenu.h>

@interface ZLViewController ()<ZLPullMenuDelegate>
/// 菜单
@property (nonatomic, strong) ZLPullMenu *menu;
/// 菜单内容
@property (nonatomic, copy) NSArray *menus;
@end

@implementation ZLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.menu];
    [self.menu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.left.right.equalTo(self.view);
        make.height.mas_equalTo(40);
    }];
}

#pragma mark - ZLPullMenuDelegate

- (void)pullMenuDidSelected:(ZLIndexPath *)indexPath {
    NSLog(@"选中下标：%ld %ld %ld", (long)indexPath.menuIndex, (long)indexPath.groupIndex, (long)indexPath.optionIndex);
}

- (ZLPullMenu *)menu {
    if (!_menu) {
        _menu = [[ZLPullMenu alloc] init];
        _menu.layoutMode = ZLPullMenuLayoutCenter;
        _menu.delegate = self;
        _menu.menus = self.menus;
    }
    return _menu;
}

- (NSArray *)menus {
    if (!_menus) {
        /// 顶部菜单样式
        ZLPullMenuConfig *menuConfig = [ZLPullMenuConfig configWithFont:[UIFont systemFontOfSize:14]
                                                           selectedFont:[UIFont systemFontOfSize:14 weight:UIFontWeightBold]
                                                              textColor:[UIColor colorWithRed:0.39 green:0.39 blue:0.39 alpha:1.00]
                                                      textSelectedColor:[UIColor colorWithRed:0.79 green:0.55 blue:0.30 alpha:1.00]
                                                             arrowColor:[UIColor colorWithRed:0.39 green:0.39 blue:0.39 alpha:1.00]
                                                     arrowSelectedColor:[UIColor colorWithRed:0.79 green:0.55 blue:0.30 alpha:1.00]];
        /// 组标题配置
        ZLPullMenuGroupConfig *groupConfig = [ZLPullMenuGroupConfig configWithFont:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
                                                                         textColor:[UIColor orangeColor]];
        /// 选项样式
        ZLPullMenuOptionpConfig *optionConfig = [ZLPullMenuOptionpConfig configWithFont:[UIFont systemFontOfSize:12]
                                                                           selectedFont:[UIFont systemFontOfSize:12 weight:UIFontWeightBold]
                                                                              textColor:[UIColor colorWithRed:0.31 green:0.31 blue:0.31 alpha:1.00]
                                                                      textSelectedColor:[UIColor blackColor]
                                                                        backgroundColor:[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00]
                                                                backgroundSelectedColor:[UIColor colorWithRed:0.98 green:0.87 blue:0.28 alpha:1.00]
                                                                            borderColor:[UIColor clearColor]
                                                                    borderSelectedColor:[UIColor colorWithRed:0.96 green:0.96 blue:0.96 alpha:1.00]];
        
        /// 以下数据配置
        /// 综合排序
        ZLPullMenuGroup *group11 = [ZLPullMenuGroup groupWithTitle:@"默认标题样式" selecteds:YES options:@[
            [ZLPullMenuOption optionWithTitle:@"专送" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"自取" selected:NO]
        ]];
        ZLPullMenuGroup *group12 = [ZLPullMenuGroup groupWithTitle:@"自定义标题样式" selecteds:YES options:@[
            [ZLPullMenuOption optionWithTitle:@"默认样式" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"自定义样式" selected:NO config:optionConfig],
            [ZLPullMenuOption optionWithTitle:@"默认选中" selected:YES],
            [ZLPullMenuOption optionWithTitle:@"60分钟" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"70分钟" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"80分钟" selected:NO]
        ] config:groupConfig];
        ZLPullMenuGroup *group13 = [ZLPullMenuGroup groupWithTitle:@"子选项多选" options:@[
            [ZLPullMenuOption optionWithTitle:@"预定" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"准时" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"放心吃" selected:NO]
        ]];
        ZLPullMenuGroup *group14 = [ZLPullMenuGroup groupWithTitle:@"子选项单选" selecteds:NO options:@[
            [ZLPullMenuOption optionWithTitle:@"商家优惠" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"随机满减" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"商品折扣" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"随机返现" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"新店立减" selected:NO]
        ]];
        ZLPullMenuItem *item1 = [ZLPullMenuItem itemWithTitle:@"自定义样式" groups:@[group11, group12, group13, group14] config:menuConfig];
        
        /// 尺寸
        ZLPullMenuGroup *group21 = [ZLPullMenuGroup groupWithTitle:@"选项" selecteds:NO options:@[
            [ZLPullMenuOption optionWithTitle:@"36码" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"37码" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"38码" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"39码" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"40码" selected:NO]
        ]];
        ZLPullMenuItem *item2 = [ZLPullMenuItem itemWithTitle:@"默认样式" groups:@[group21]];
        
        
        /// 颜色
        ZLPullMenuGroup *group31 = [ZLPullMenuGroup groupWithTitle:@"选项" options:@[
            [ZLPullMenuOption optionWithTitle:@"黄色" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"白色" selected:NO],
            [ZLPullMenuOption optionWithTitle:@"蓝色" selected:NO]
        ]];
        ZLPullMenuItem *item3 = [ZLPullMenuItem itemWithTitle:@"默认样式" groups:@[group31]];
        _menus = @[item1, item2, item3];
    }
    return _menus;
}

@end
